package org.example.repository;

import java.time.LocalDateTime;
import java.util.List;
import org.example.entity.UserLogDO;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;

/**
 * 用户操作日志仓库接口
 */
public interface UserLogRepository extends JpaRepository<UserLogDO, Integer> {

    @EntityGraph(attributePaths = {"userId", "operationType", "operationTime", "details"})
    List<UserLogDO> findByUserIdAndOperationTypeAndOperationTimeBetween(Integer userId, UserLogDO.OperationType operationType, LocalDateTime startTime, LocalDateTime endTime);

    @EntityGraph(attributePaths = {"userId", "operationType", "operationTime", "details"})
    List<UserLogDO> findByUserIdAndOperationTimeBetween(Integer userId, LocalDateTime startTime, LocalDateTime endTime);

    @EntityGraph(attributePaths = {"userId", "operationType", "operationTime", "details"})
    List<UserLogDO> findByOperationTypeAndOperationTimeBetween(UserLogDO.OperationType operationType, LocalDateTime startTime, LocalDateTime endTime);

    @EntityGraph(attributePaths = {"userId", "operationType", "operationTime", "details"})
    List<UserLogDO> findByOperationTimeBetween(LocalDateTime startTime, LocalDateTime endTime);
}